import { createHelia } from 'helia'
import { strings } from '@helia/strings'
import {CID} from "multiformats";

// 创建Helia实例
const helia = await createHelia()

// 字符串传输实例
const heliaStr = strings(helia)

// 添加一个字符串
const cid1 = await heliaStr.add('hello world')
console.log("CID =", cid1.toString())

// 根据CID获取字符串内容
const cid2 = CID.parse('bafkreifzjut3te2nhyekklss27nh3k72ysco7y32koao5eei66wof36n5e')
const str = await heliaStr.get(cid2)
console.log("根据CID获取字符串:", str)